﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.ComponentModel.Composition;
using Microsoft.Practices.Prism;
using Microsoft.Practices.ServiceLocation;
using ChrizNet.Infrastructure;
using ChrizNet.SearchService;
using System.Reflection;

namespace ChrizNet.UI
{
    /// <summary>
    /// Interaction logic for UserControl1.xaml
    /// </summary>
    [ViewExport(RegionName = RegionNames.MAIN_CONTENT_REGION)]
    public partial class UserControl1 : UserControl
    {
        public UserControl1()
        {
            InitializeComponent();
            GoogleWebSearch gwebSearch = new GoogleWebSearch();
            string retval = gwebSearch.GetResults("penang");
            //HideScriptErrors(myWebBrowser, true);
            //myWebBrowser.NavigateToString(retval);
            
        }

        public void HideScriptErrors(WebBrowser wb, bool Hide)
        {
            FieldInfo fiComWebBrowser = typeof(WebBrowser).GetField("_axIWebBrowser2", BindingFlags.Instance | BindingFlags.NonPublic);
            if (fiComWebBrowser == null) return;
            object objComWebBrowser = fiComWebBrowser.GetValue(wb);
            if (objComWebBrowser == null) return;
            objComWebBrowser.GetType().InvokeMember("Silent", BindingFlags.SetProperty, null, objComWebBrowser, new object[] { Hide });
        }
    }
}
